package com.yuanfeng.business.controller;

import com.yuanfeng.business.dto.GateOpenDTO;
import com.yuanfeng.business.dto.GateQueryStoreDTO;
import com.yuanfeng.commoms.dto.shop.GateStoreUpdateDTO;
import com.yuanfeng.commoms.util.ResponseResult;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @ClassName ShopGateController
 * @Description 门店账号
 * @Author hyq
 * @Date 2023/5/18 16:46
 * @Version 1.0
 **/
@RestController
@RequestMapping("/shop/gate")
public class ShopGateController extends BaseController {


    /**
     * 根据userId查门店账号信息
     *
     * @param map
     * @return
     */
    @PostMapping("/query/GateShopIdUserId")
    public ResponseResult queryGateShopIdByUserId(@RequestBody Map<String, String> map) {

        return shopGateService.queryGateShopIdByUserId(map);
    }

    /**
     * 查询当前用户是否是门店账号
     */
    @PostMapping("/queryUserIsGate")
    public Integer queryUserIsGate(@RequestBody Map<String,String> map) {

        return shopGateService.queryUserIsGate(map.get("userMobile"));
    }
    /**
     * 更新门店自提订单销量库存
     *
     * @return
     */
    @PostMapping("/update/shopGate/stock")
    public ResponseResult updateShopGateStock(@RequestParam String saleSum){
        return shopGateService.updateShopGateStock(saleSum);
    }

    /**
     * 商品门店查询
     * @param param
     * @return
     */
    @PostMapping("/queryGateDetail")
    public ResponseResult queryGateDetail(@RequestBody Map<String,Object> param) {
        return shopGateService.queryGateDetail(param);
    }

    /**
     * 查询是否门店
     */
    @PostMapping("/isShopGate")
    public ResponseResult isShopGate(@RequestBody Map<String, String> paraMap) {
        return shopGateService.isShopGate(paraMap);
    }
    /**
     * 商品门店查询
     * @param gateQueryStoreDTO
     * @return
     */
    @PostMapping("/queryGateStore")
    public ResponseResult queryGateStore(@RequestBody GateQueryStoreDTO gateQueryStoreDTO) {
        return shopGateService.queryGateStore(gateQueryStoreDTO);
    }

    /**
     * 查询门店店铺名称
     * @param orderGateShopId
     * @return
     */
    @PostMapping("/queryGateStoreName")
    public String queryGateStoreName(@RequestParam("orderGateShopId") Integer orderGateShopId) {
        return shopGateService.queryGateStoreName(orderGateShopId);
    }

    /**
     * 开启门店接口（支持批量开启）
     * @param gateOpenDTO
     * @return
     */
    @PostMapping("/openGateStore")
    public ResponseResult openGateStore(@RequestBody(required = true) GateOpenDTO gateOpenDTO){
        ResponseResult result=shopGateService.openGateStore(gateOpenDTO);
        return result;
    }

    /**
     * 关闭门店接口
     * @param gateCloseDTO
     * @return
     */
    @PostMapping("/stopGateStore")
    public ResponseResult stopGateStore(@RequestBody(required = true) GateOpenDTO gateCloseDTO){
        ResponseResult result=shopGateService.stopGateStore(gateCloseDTO);
        return result;
    }

    /**
     * 编辑门店信息接口
     * @param gateStoreUpdateDTO
     * @return
     */
    @PostMapping("/updateGateStore")
    public ResponseResult updateGateStore(@RequestBody GateStoreUpdateDTO gateStoreUpdateDTO){
        ResponseResult result=shopGateService.updateGateStore(gateStoreUpdateDTO);
        return result;
    }


    /**
     * 门店查询接口
     * @param gateStoreQueryDTO
     * @return
     */
    @PostMapping("/queryGateStoreByPage")
    public ResponseResult queryGateStoreByPage(@RequestBody GateQueryStoreDTO gateStoreQueryDTO) throws IllegalAccessException {
        ResponseResult result=shopGateService.queryGateStoreByPage(gateStoreQueryDTO);
        return result;
    }

    /**
     * 查询附近门店
     * @param param
     * @return
     */
    @PostMapping("/h5/queryShopNearBy")
    public ResponseResult queryShopNearBy(@RequestBody Map<String,Object> param) {
        return shopGateService.queryShopNearBy(param);
    }

    /**
     * 查询门店商品
     * @param param
     * @return
     */
    @PostMapping("/queryGoods")
    public ResponseResult queryGoods(@RequestBody Map<String,Object> param) {
        ResponseResult result = shopGateService.queryGoods(param);
        return result;
    }

}
